<?php
namespace app\admin\controller;
use think\Loader;
use think\Cache;
class Adporttwo extends Base{

    //管理员新增操作
    function adminAdd(){
        $invoking     = Loader::model('Account','service');
        $input = input();
        $parr['admin_id'] = trim($input['admin_id']);
        if(empty($parr['admin_id'])){
            $parr['a_username']=trim($input['a_username']);
            $parr['a_password']=trim($input['a_password']);
        }
        $parr['a_role']    =trim($input['a_role']);
        $parr['a_fullname']=trim($input['a_fullname']);
        $parr['a_phone']   =trim($input['a_phone']);
        $parr['a_img']     =trim($input['a_img']);
        $data=$invoking->adminAddApi($parr);
        return json($data);
    }

    //管理员删除
    public function adminDelete(){
        $invoking     = Loader::model('Account','service');
        $admin_id=trim(input('admin_id'));
        $data=$invoking->adminDeleteApi($admin_id);
        return json($data);
    }




    //管理员更改密码操作
    function adminChange(){
        $invoking     = Loader::model('Account','service');
        $input        = input();
        $parr['admin_id']       =   trim($input['admin_id']);
        $parr['userpassword']   =   trim($input['userpassword']);
        $parr['userpassword2']  =   trim($input['userpassword2']);
        $data=$invoking->adminChangeApi($parr);
        return json($data);
    }


    //权限分配
    public function permissionDistribution(){
        try{
            set_time_limit(0);
            $invoking     = Loader::model('Account','service');
            $input        = input();
            $admin_function_id  = $input['admin_function_id'];
            $admin_role_id      = $input['admin_role_id'];
            $response=$invoking->permissionDistributionApi($admin_function_id,$admin_role_id);
        } catch (\Exception $e) {
            $response      = messageInfo ( '101', '服务器错误！' );
        }

        return json($response);
    }

    //菜单 添加
    public function menusAddData(){
        $invoking     = Loader::model('Account','service');
        $input        = input();
        $parr['am_mname'] = $input['am_mname'];
        $parr['am_murl']  = $input['am_murl'];
        $parr['am_sort']  = $input['am_sort'];
        $parr['admin_menu_id'] = $input['admin_menu_id'];
        $data=$invoking->menusAddApi($parr);
        return json($data);
    }

    //子菜单新增接口
    public function sonmenusAddData(){
        $invoking     = Loader::model('Account','service');
        $input        = input();
        $parr['am_mname']      = $input['am_mname'];
        $parr['admin_menu_id'] = $input['admin_menu_id'];
        $parr['am_sort']       = $input['am_sort'];
        $parr['am_murl']       = $input['am_murl'];
        $parr['am_pid']        = $input['am_pid'];
        $data=$invoking->sonmenusAddApi($parr);
        return json($data);
    }


    //菜单删除
    public function sonmenusDelete(){
        $invoking = Loader::model('Account','service');
        $where['admin_menu_id'] = trim(input('admin_menu_id'));
        $data=$invoking->sonmenusDeleteApi($where);
        return json($data);
    }


    //三级功能添加接口
    public function functionData(){
        $invoking = Loader::model('Account','service');
        $input        = input();
        $parr['am_pid']        = $input['am_pid'];
        $parr['admin_menu_id'] = $input['admin_menu_id'];
        $parr['af_furl']       = $input['af_furl'];
        $parr['af_fname']      = $input['af_fname'];
        $parr['admin_function_id'] = $input['admin_function_id'];
        $parr['af_strte']      = $input['af_strte'];
        $data=$invoking->functionAddApi($parr);
        return json($data);
    }

    //三级功能删除
    public function funDetele(){
        $invoking = Loader::model('Account','service');
        $admin_function_id=trim(input('admin_function_id'));
        $data=$invoking->fuDeteleApi($admin_function_id);
        return json($data);
    }


    //角色新增与编辑（操作）
    public function rolesHandle(){
        $input = input();
        $invoking = Loader::model('Account','service');
        $data=$invoking->rolesHandleApi($input);
        return json($data);
    }

    //角色删除
    public function rolesDelete(){
        $role_id = trim(input('role_id'));
        $invoking = Loader::model('Account','service');
        $data=$invoking->rolesDeleteApi($role_id);
        return json($data);
    }


    //文书分类新增与编辑
    public function writTyupeRequest(){
        $input   = input();
        $wt_name      = $input['wt_name'];
        $wt_sort      = $input['wt_sort'];
        $writ_type_id = $input['writ_type_id'];
        $invoking = Loader::model('Front','service');
        $data=$invoking->writTyupeRequestApi($wt_name,$wt_sort,$writ_type_id);
        return json($data);
    }

    //文书分类删除
    public function writTypeDelete(){
        $writ_type_id = input('writ_type_id');
        $invoking     = Loader::model('Front','service');
        $data         = $invoking->writTypeDeleteApi($writ_type_id);
        return json($data);
    }





    //文书新增与编辑
    public function writPresent(){
        $input = input();
        $file  = request()->file("file");
        $parr['w_title']        = $input['w_title'];
        $parr['writ_type_id']   = $input['writ_type_id'];
        $parr['w_describe']     = $input['w_describe'];
        $parr['w_state']        = $input['w_state'];
        $parr['w_sort']         = $input['w_sort'];
       /* $parr['w_writ_img']     = $input['w_writ_img'];*/
        $parr['w_industry']     = $input['w_industry'];
        $parr['w_copyright']     = $input['w_copyright'];
        $parr['writ_id']        = $input['writ_id'];
        $invoking     = Loader::model('Front','service');
        $data         = $invoking->writPresentApi($parr,$file);
        return json($data);
    }

    //文书删除
    public function writDelete(){
        $writ_id = input('writ_id');
        $invoking     = Loader::model('Front','service');
        $data         = $invoking->writDeleteApi($writ_id);
        return json($data);
    }

    //文书操作
    public function writAnnounce(){
        $writ_id = input('writ_id');
        $invoking     = Loader::model('Front','service');
        $data         = $invoking->writAnnounceApi($writ_id);
        return json($data);
    }

    //律师展示新增与编辑
    public function lawyerPresent(){
        $input = input();
        $lawyer_id                = $input['lawyer_id'];
        $parr['l_name']           = $input['l_name'];
        $parr['l_office']         = $input['l_office'];
        $parr['l_describe']       = $input['l_describe'];
        $parr['l_img']            = $input['l_img'];
        $parr['l_state']          = $input['l_state'];
        $parr['l_sort']           = $input['l_sort'];

        $parr['l_age']            = $input['l_age'];
        $parr['l_code']           = $input['l_code'];
        $parr['l_site']           = $input['l_site'];
        $parr['l_field']          = $input['l_field'];
        $parr['l_details']        = $_POST['l_details'];

        $invoking     = Loader::model('Front','service');
        $data         = $invoking->lawyerPresentApi($parr,$lawyer_id);
        return json($data);
    }

    //删除律师展示
    public function lawyerDelet(){
        $lawyer_id    = input('lawyer_id');
        $invoking     = Loader::model('Front','service');
        $data         = $invoking->lawyerDeletApi($lawyer_id);
        return json($data);
    }


    //轮播图上传
    public function carouselImg(){
        $parameter = input();
        $carousel_img       = $parameter['carousel_img'];
        $carousel_url       = $parameter['carousel_url'];
        $invoking              = Loader::model('Front','service');
        $response              = $invoking->carouselImgApi($carousel_img,$carousel_url);
        return json($response);
    }

    //短信推送设置
    public function consulPushRequest(){
        $a_username          = input('a_username');
        $leave_type             = input('leave_type');
        $invoking              = Loader::model('Consul','service');
        $response              = $invoking->consulPushRequestApi($a_username,$leave_type);
        return json($response);
    }

    //短信推送删除
    public function consulPushDelete(){
        $consult_push_sie_id         = input('consult_push_sie_id');
        $invoking              = Loader::model('Consul','service');
        $response              = $invoking->consulPushDeleteApi($consult_push_sie_id);
        return json($response);
    }


    //咨讯分类新增与编辑
    public function newsTypeRequest(){
        $input   = input();
        $nt_name      = $input['nt_name'];
        $nt_sort      = $input['nt_sort'];
        $news_type_id = $input['news_type_id'];
        $invoking = Loader::model('Front','service');
        $data=$invoking->newsTypeRequestApi($nt_name,$nt_sort,$news_type_id);
        return json($data);
    }

    //咨讯分类删除
    public function newsTypeDelete(){
        $news_type_id         = input('news_type_id');
        $invoking              = Loader::model('Front','service');
        $response              = $invoking->newsTypeDeleteApi($news_type_id);
        return json($response);
    }

    //咨讯新增与编辑
    public function newsAnyRequest(){
        $input   = input();
        $invoking = Loader::model('Front','service');
        $data=$invoking->newsAnyRequestApi($input);
        return json($data);
    }

    //咨讯删除
    public function newsDelete(){
        $news_id = input('news_id');
        $invoking = Loader::model('Front','service');
        $data=$invoking->newsDeleteApi($news_id);
        return json($data);
    }

    //咨讯发布
    public function newsIssue(){
        $news_id = input('news_id');
        $invoking = Loader::model('Front','service');
        $data=$invoking->newsIssueApi($news_id);
        return json($data);
    }

    //顾问卡编辑与新增
    public function counselorAnyRequest(){
        $input                 = input();
        $parr['ck_name']       = $input['ck_name'];
        $parr['ck_price']      = $input['ck_price'];
        $parr['ck_sort']       = $input['ck_sort'];
        $parr['ck_ps']         = $input['ck_ps'];
        $parr['counselor_id']  = $input['counselor_id'];
        $invoking = Loader::model('Front','service');
        $data=$invoking->counselorAnyRequestpi($parr);
        return json($data);
    }

    //顾问卡删除
    public function counselorDelete(){
        $counselor_id = input('counselor_id');
        $invoking = Loader::model('Front','service');
        $data=$invoking->counselorDeleteApi($counselor_id);
        return json($data);
    }


    //友情地址新增与编辑
    public function  linksRequest(){
        $input                 = input();
        $invoking = Loader::model('Front','service');
        $data=$invoking->linksRequestApi($input);
        return json($data);
    }

    //友情查询
    public function linkFind(){
        $links_id = input('links_id');
        $invoking = Loader::model('Front','service');
        $data=$invoking->linkFindApi($links_id);
        return json($data);
    }

    //友情链接删除
    public function linkDelete(){
        $links_id = input('links_id');
        $invoking = Loader::model('Front','service');
        $data=$invoking->linkDeleteApi($links_id);
        return json($data);
    }

    //tkd新增与编辑
    public function tkdRequest(){
        $input                 = input();
        $invoking = Loader::model('Front','service');
        $data=$invoking->tkdRequestApi($input);
        return json($data);
    }

    //tkd查询
    public function  tkdFind(){
        $tkd_id = input('tkd_id');
        $invoking = Loader::model('Front','service');
        $data=$invoking->tkdFindApi($tkd_id);
        return json($data);
    }

    //tkd删除
    public function  tkdDelete(){
        $tkd_id = input('tkd_id');
        $invoking = Loader::model('Front','service');
        $data=$invoking->tkdDeleteApi($tkd_id);
        return json($data);
    }

    //留言删除与已读
    public function leaveRequest(){
        $state = input('state');
        $leave_id = input('leave_id');
        $invoking = Loader::model('Front','service');
        $data=$invoking->leaveRequestApi($leave_id,$state);
        return json($data);
    }

    //清除缓存
    public function clear_sys(){
        Cache::clear();//清除模版缓存 不删除cache目录
        return  json(messageInfo('202','清除成功'));
    }

    //留言标记已读(多选)
    public function leaveRequestAs(){
        try{
            $input = input();
            $leave_id = $input['leave_id'];
            $invoking = Loader::model('Front','service');
            $data=$invoking->leaveRequestAsApi($leave_id);
        } catch (\Exception $e) {
            $response      = messageInfo ( '101', '服务器错误！' );
        }
        return json($data);
    }

}
